
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title"><font color="red">[<span id="data-cname"></span>]科目条目管理</font>&nbsp;</h4>
			</div>
			<div class="modal-body" style="min-height:400px;">
				<center>
			         <div class="btn-group" style="margin:0 0 10px 0;">
						<button class="btn btn-info" type="button" onclick="toItemAdd()">增加</button>
						<button class="btn btn-info" type="button" onclick="toItemEdit();">修改</button>
						<button class="btn btn-info" type="button" onclick="getDataItems();">刷新</button>
					</div>					
				</center>
				<center>
					<form id="searchItemFrom" class="form-horizontal">
						<input type="hidden" name="doCode" value="dictItemList"/><!-- ----- -->
						<input type="hidden" name="cateEname" id="form_cateEname"/>
						条目名称：<input type="text" class="form-control" style="height: 30px; display: inline; width: 13%;"  name="itemText" id="itemText" value="" />
						条目值：<input type="text" class="form-control" style="height: 30px; display: inline; width: 13%;"  name="itemValue" id="itemValue" value="" />
						<button type="button" class="btn btn-primary" onclick="getDataItems();">查询</button>
						<button  type="button" class="btn btn-primary" onclick="cleanData('searchItemFrom');">重置</button>
					</form>
				</center>
		         <table id="tabItems" class="table table-bordered " >
		             <thead>
		                <tr>
		              	  <th>科目名称</th>
		                  <th>科目标识</th>
		                  <th>状态</th>
		                  <th>描述</th>
		                  <th>操作</th>
		                </tr>
		              </thead>
		              <tbody id="dataItmes"> </tbody>
		          </table>
		    </div>

 <div class="modal fade" id="my_modal_item" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><font color="red">条目信息</font>&nbsp;</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" role="form" id="dataItemForm">
					<input type="hidden" name="formToken" id="formToken" value="${formToken}"/>
					<input type="hidden" name="doCode" value="dictItemSave"/>
					<input type="hidden" name="cateEname" id="data-cateEname"/>
					<input type="hidden" name="fatherId" id="data-fatherId"  value="0"/>
					<input type="hidden" name="itemId" id="data-itemId" value=""/>
					<div class="box-body" id="orgFormData">
			           <div class="form-group">
			              <label  class="col-sm-4 control-label" >条目名称</label>
			                  <div class="col-sm-6">
			                    <input type="text" class="form-control" data-name="itemText"   name="itemText" required placeholder="必填项">
			                  </div>
			                </div>
			                <div class="form-group">
			                  <label class="col-sm-4 control-label">条目值</label>
			                  <div class="col-sm-6">
			                    <input type="text" class="form-control" data-name="itemValue"  name="itemValue" required placeholder="必填项">
			                  </div>
			                </div>
			                <div class="form-group">
			                  <label class="col-sm-4 control-label">子节点数</label>
			                  <div class="col-sm-6">
			                    <input type="text" class="form-control" data-name="subCount" name="subCount" value="0">
			                  </div>
			                </div>
			                <div class="form-group">
			                  <label class="col-sm-4 control-label">描述</label>
			                  <div class="col-sm-6">
			                    <input type="text" class="form-control" data-name="itemRemark"  name="itemRemark" placeholder="">
			                  </div>
			                </div>
			                <div class="form-group">
			                  <label class="col-sm-4 control-label">状态</label>
			                  <div class="col-sm-6">
			                    <input type="radio" checked="checked" value="1" name="itemStatus"> <i></i> 启用 
                                <input type="radio" value="0" name="itemStatus"> <i></i> 停用
			                  </div>
			                </div>
			              </div>
			               <div class="box-footer">
			                <button type="button" class="btn btn-primary pull-left" onclick="cannelItem();">取消</button>
			                <button type="button" class="btn btn-primary pull-right" onclick="saveItem('dataItemForm');">提 交</button>
			              </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
<script type="text/template" id="dataItemList">
	 <? for ( var i = 0; i < rows.length; i++) {?>
		<tr id="<?=rows[i].itemId?>" treeLevel="<?=rows[i].treeLevel?>" fatherId="<?=rows[i].fatherId?>">
			<th style="display:none;"><?=rows[i].itemId?></th>
			<th style="display:none;"><?=rows[i].treeLevel?></th>
			<th style="display:none;"><?=rows[i].fatherId?></th>
			<td><?if(rows[i].subCount>0){?>
				<i class="fa fa-folder" onclick="getChildTableData('<?=rows[i].itemId?>','<?=rows[i].fullEname?>',this);">&nbsp;<?=rows[i].itemText?></i>
				<?} else{?>	<i class="fa fa-file"></i>&nbsp;<?=rows[i].itemText?>
				<?}?></td>
			<td><?=rows[i].itemValue?></td>
			<td><?if("1"==rows[i].itemStatus){?><font color=blue>启用</font>
                <?}else{?><font color=red>停用</font><?}?>
            </td>
			<td><?=rows[i].itemRemark?></td>
            <td><a href="javascript:void(0);" onclick="delItem('<?=rows[i].itemId?>','<?=rows[i].cateEname?>');">删除</a>|
              <a href="javascript:void('0');" onclick="toSubItemAdd('<?=rows[i].itemId?>')">增加子条目</a></td>
		</tr>
     <?}?>
</script>
<script>
var itemId;
function loadItems(cateEname,cname){
   $("#form_cateEname").val(cateEname);
   $("#data-cname").html(cname);
   getDataItems();
   $('#tabItems tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     itemId = $('tr.selected th').eq(0).html();
	} );
}
function getDataItems(){
	$.ajax({url:common_list_url,async:false,type: "get",
			data:$('#searchItemFrom').serialize(),dataType: "json",
		    success: function(myData){
		    //console.log(myData);
			   var data = baidu.template('dataItemList',myData);  
			  // alert(data);
			   $("#dataItmes").html(data);
		   }
	  });	
  }
  //打开查看详情win
	function toItemEdit(){
	    setToken();
		$.ajax({type:'get',url:common_info_url,
		    data:{'itemId':itemId,'doCode':'dictItemView'},
		    dataType:'json',
		    success: function(myData){
		    	FormUtil.loadView("", myData);
		    	$("#data-cateEname").val(myData.cateEname);
		    	$("#data-fatherId").val(myData.fatherId);
		    	$("#data-itemId").val(myData.itemId);
				 $('#my_modal_item').modal('show');
		  	}
		});	
	}
	function toItemAdd(){
	    setToken();
	    $("#data-cateEname").val($("#form_cateEname").val());
	    $('#my_modal_item').modal('show');
	}
	function toSubItemAdd(itemId){
	     setToken();
	    $("#data-fatherId").val(itemId);
	    $("#data-cateEname").val($("#form_cateEname").val());
	    $('#my_modal_item').modal('show');
	}
  function saveItem(formId){
	if(!$("#" + formId)[0].checkValidity()){
		alert("请先完善必输项和必选项！");
		return ;
	}
	$.ajax({ type:'post',url:common_submit_url,
	    data:$("#"+formId).serialize(), dataType:'json',
	    success: function(myData){
	    	//console.log(myData);
	    	if(myData.flag=='T'){
	    		layer.alert('操作成功！', {skin:'layui-layer-molv',closeBtn:0});
	    		$('#my_modal_item').modal('hide');
	    		getDataItems();
	    	}else{alert(myData.msg);}
	  	}
	});	
}
function cannelItem(){
	$('#my_modal_item').modal('hide');
}

function getChildTableData(id,treeLevel,obj){
var count =0;
var ss = treeLevel.split("/");
count = ss.length-1;
    var cateNamestr=$("#form_cateEname").val();
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:{'id':id,cateEname:cateNamestr,'doCode':'dictItemList'},
		   dataType:'json',
		   success: function(myData){
			var data = baidu.template('dataItemList',myData);  
			if($(obj).hasClass("fa-folder-open")){
				$(obj).attr("class","fa fa-folder");
				delChiled(id);
			}else{
				$(obj).attr("class","fa fa-folder-open");
				$("#"+id).after(data);
				 $("[fatherid='"+id+"']").each(function(i){
					var thisObj = $(this);
					var pd = "10px 20px 10px ";
					var num = pd+(count*20)+"px";
					$(thisObj).find("td").eq(0).css("padding",num);
				 });
			}
		   }
		});	
  } 
   function delChiled(id){
	  $("[fatherid='"+id+"']").each(function(i){
			 var thisObj = $(this);
			 $(thisObj).remove();
			 var id = thisObj.attr("id");
			 delChiled(id);
		 });
	  
  }
  function delItem(itemId,cateEname){
      layer.confirm('您确认要进行删除操作？', { btn: ['确认','取消'] },
		   function(){
		    $.ajax({type:'post',url:common_submit_url,
				    data:{'itemId':itemId,'doCode':'dictItemDel','cateEname':cateEname},
				    dataType:'json',
				    success: function(myData){
				    	if(myData.flag=='T'){
				    		layer.alert('操作成功！', {skin: 'layui-layer-molv',closeBtn: 0 });
				    		getDataItems();
				    	}
		
				  	}
				});	
	      }, 
		   function(){}
	   );
	}
</script>